home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / D51_NARexx / PlayMod_DT.dopus5 < prev    next >
Text File  |  1995-12-25  |  6KB  |  149 lines

  1. /* Mod-Player interface for Directory Opus 5.
  2.  By Leo 'Nudel' Davidson for Gods'Gift Utilities
  3.  email: leo.davidson@keble.oxford.ac.uk  www: http://info.ox.ac.uk/~kebl0364/
  4.  
  5. $VER: PlayMod_DT.dopus5 1.3 (25.12.95)
  6.  
  7.    This version is for use with DeliTracker by Peter Kunath & Frank Riffel
  8.    (Delirium Softdesign), but should be easy to adapt to any other player
  9.    with an ARexx port, such as MultiPlayer, EagleTracker, DMP, etc.
  10.    (In fact, a MultiPlayer version should come with this script!).
  11.  
  12.    If you include the path of a module on the command line, using {f}, only
  13.    this mod will be played. If you omit the {f}, the program will play each
  14.    selected file in the first SOURCE lister, giving you a requester to go to
  15.    the next file or stop playing.
  16.  
  17.    If the player's ARexx port is not found, the program will be run for
  18.    you (you should edit the path below). This means the script may fail if
  19.    you disable the player's ARexx port, or give an incorrect command line
  20.    to it.
  21.    If the player's ARexx port takes over a minute to appear, an error
  22.    requester will appear on the DOpus screen and the script will quit.
  23.    REMEMBER to add the "RUN" command to the player command line if it does
  24.    not automatically detach from the shell (DeliTracker doesn't)!
  25.  
  26.    If the player was running to start with, or the user selects
  27.    "Leave Playing", the module will continue playing when the script finishes.
  28.    Otherwise, the player will be quit.
  29.  
  30. Call as:
  31. ------------------------------------------------------------------------------
  32. ARexx    DOpus5:ARexx/PlayMod_DT.dopus5 {Qp} [{f}]
  33. ------------------------------------------------------------------------------
  34. Turn off all switches.
  35. "[]" means this part is optional.
  36.  
  37.    v1.00 -> v1.01 - Now uses stem variables to get the lister handle.
  38.                     Some minor tidying up.
  39.                     Now checks to make sure the DOPUS.x port exists.
  40.     v1.01 -> v1.2 - Now uses Show() instead of ShowList(). (Thanks Stoebi)
  41.                     Style Guide compliant version numbering and $VER string.
  42.      v1.2 -> v1.3 - Changed the way it loads the mod-player into memory
  43.                     as it was causing problems.
  44.                   - I think there were some problems with filenames containing
  45.                     spaces but they're no longer here as far as I can tell.
  46.                     (Maybe I fixed them and forgot that I'd done it...)
  47.  
  48. */
  49. /*- Path to DeliTracker command --------------------------------------------*/
  50. DeliTracker = "RUN >NIL: <NIL: DH0:Tools/Music/DeliTracker2"
  51. /*--------------------------------------------------------------------------*/
  52. options results
  53. options failat 99
  54. signal on syntax;signal on ioerr        /* Error trapping */
  55. parse arg DOpusPort FilePath
  56. DOpusPort = Strip(DOpusPort,"B",'" ')
  57. FilePath = Strip(FilePath,"B",'" ')
  58.  
  59. If DOpusPort="" THEN Do
  60.     Say "Not correctly called from Directory Opus 5!"
  61.     Say "Load this ARexx script into an editor for more info."
  62.     EXIT
  63.     END
  64. If ~Show("P",DOpusPort) Then Do
  65.     Say DOpusPort "is not a valid port."
  66.     EXIT
  67.     End
  68. Address value DOpusPort
  69.  
  70. Quit_After = "NO"
  71. If ~Show("P","DELITRACKER") Then Do
  72.     Address Command DeliTracker
  73.     Address Command "WaitForPort DELITRACKER"
  74.     Quit_After = "YES"
  75.     If ~Show("P","DELITRACKER") then do
  76.         dopus request '"Error loading DeliTracker!'|| '0a'x ||'Check its command-path in the ARexx script itself." OK'
  77.         EXIT
  78.         END
  79.     END
  80.  
  81. /* If file-path was specified on command line, just play that mod, else
  82.    go through all the selected ones. */
  83.  
  84. If FilePath = "" Then Do
  85.  
  86.     lister query source stem source_handle.
  87.     IF source_handle.count = 0 | source_handle.count = "SOURCE_HANDLE.COUNT" Then Do
  88.         dopus request '"You must have a SOURCE lister!" OK'
  89.         EXIT
  90.         End
  91.     lister set source_handle.0 busy 1
  92.  
  93.     lister query source_handle.0 numselentries    /* Get info about selected */
  94.     Lister_NumSelEnt = RESULT            /* entries & path to them */
  95.     lister query source_handle.0 path
  96.     Lister_Path = Strip(RESULT,"B",'"')
  97.  
  98.     Do i=1 to Lister_NumSelEnt
  99.         lister query source_handle.0 firstsel
  100.         Temp_Name = Strip(RESULT,"B",'"')
  101.         lister select source_handle.0 Temp_Name 0
  102.         Temp_Path = Lister_Path||Temp_Name
  103.         Address DELITRACKER PlayMod Temp_Path
  104.  
  105.         If Lister_NumSelEnt - i > 0 Then Do
  106.             If Quit_After = "YES" Then
  107.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':'||X2C(0A)||Temp_Name||'" Next|Leave Playing|Stop'
  108.             Else
  109.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':'||X2C(0A)||Temp_Name||'" Next|Leave Playing'
  110.             IF RC = "0" THEN BreakIt = "YES"
  111.             IF RC = "2" THEN Do
  112.                 BreakIt = "YES"
  113.                 Quit_After = "NO"
  114.                 END
  115.             End
  116.  
  117.         Else Do
  118.             If Quit_After = "YES" Then
  119.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':'||X2C(0A)||Temp_Name||'" Leave Playing|Stop'
  120.             Else
  121.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':'||X2C(0A)||Temp_Name||'" Leave Playing'
  122.             IF RC = "1" Then Quit_After = "NO"
  123.             End
  124.  
  125.         IF BreakIt = "YES" THEN BREAK
  126.         END
  127.     End
  128.  
  129. ELSE Do
  130.     Address DELITRACKER PlayMod FilePath
  131.     If Quit_After = "YES" Then
  132.         dopus request '"Playing module:'||X2C(0A)||FilePath'" Leave Playing|Stop'
  133.     Else
  134.         dopus request '"Playing module:'||X2C(0A)||FilePath'" Leave Playing'
  135.     IF RC ~= "0" THEN Quit_After = "NO"
  136.     End
  137.  
  138. /*-- Restore the Lister for normal use --------------------------------------*/
  139. syntax:;ioerr:                /* In case of error, jump here */
  140. END_PART_2:
  141. If FilePath = "" Then Do
  142.     lister refresh source_handle.0
  143.     lister set source_handle.0 busy 0
  144.     END
  145. END_PART:
  146. If Quit_After = "YES" Then Address DELITRACKER QUIT
  147.  
  148. EXIT
  149.